package com.fish.job;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.fish.common.constant.Constant;
import com.fish.passport.po.PassCode;
import com.fish.service.passport.MakePassCodeService;
import com.fish.service.passport.PassCodeService;

/**
 * 通关码重新申请
 * @author chenlinjun
 *
 */
public class ReApplyPassCodeJob {
	private static final Log log = LogFactory.getLog(ReApplyPassCodeJob.class);
	private MakePassCodeService makePassCodeService;
	private PassCodeService passCodeService;
	
	public void run(){
	if (Constant.isJobRunnable()) {
			log.info("System Reapply");
			List<PassCode> list=makePassCodeService.selectByReapplyTime();
			for(PassCode passCode:list){
				log.info(" Reapply CodeId: "+passCode.getCodeId());
				String newCodeId = makePassCodeService.reApplyCode(passCode.getCodeId());
				if (newCodeId!=null) {
					log.info(" Reapply new CodeId: "+newCodeId);
					passCodeService.onApply(newCodeId);
				}
			}
		}
	}

	public void setMakePassCodeService(MakePassCodeService makePassCodeService) {
		this.makePassCodeService = makePassCodeService;
	}

	public void setPassCodeService(PassCodeService passCodeService) {
		this.passCodeService = passCodeService;
	}

}
